package com.jwsoft.manager.core.gateway.controller;

import com.bifang.assistant.common.vo.BaseVO;
import com.jwsoft.manager.common.enums.DataTaskEnum;
import com.jwsoft.manager.common.enums.JhSyncImportEnum;
import com.jwsoft.manager.common.vo.eduSyncJhImportBatch.JhSynCImportTypeVO;
import com.jwsoft.manager.core.integration.EduSyncJhImportBatchIntegration;
import com.jwsoft.manager.common.vo.eduSyncJhImportBatch.EduSyncJhImportBatchVO;
import com.jwsoft.manager.common.vo.eduSyncJhImportBatch.EduSyncJhImportBatchKeyVO;
import com.jwsoft.manager.common.vo.eduSyncJhImportBatch.EduSyncJhImportBatchQueryVO;
import com.github.pagehelper.PageInfo;
import com.bifang.engine.assistant.core.domain.AppResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import com.bifang.engine.protect.core.annotation.Idempotent;
import org.springframework.validation.annotation.Validated;
import com.bifang.assistant.common.constants.Validators;

import java.util.ArrayList;
import java.util.List;

/**
 * 金华市教育同步导入批次表网关
 *
 * @author zhiyuan
 * @since 2024-04-11
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "金华市教育同步导入批次表", description = "金华市教育同步导入批次表")
public class EduSyncJhImportBatchController {

    @Autowired
    public EduSyncJhImportBatchIntegration eduSyncJhImportBatchIntegration;

    @Operation(summary = "金华市教育同步导入批次表分页查询",description = "金华市教育同步导入批次表分页查询")
    @PostMapping(value = "/syncJhImportBatch0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduSyncJhImportBatchVO>> getList(@RequestBody @Validated EduSyncJhImportBatchQueryVO vo) {
        return AppResponse.successData(eduSyncJhImportBatchIntegration.getList(vo));
    }

    @Operation(summary = "金华市教育同步导入批次表根据主键查询详情",description = "金华市教育同步导入批次表根据主键查询详情")
    @PostMapping(value = "/syncJhImportBatch0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSyncJhImportBatchVO> getById(@RequestBody @Validated EduSyncJhImportBatchKeyVO vo) {
        return AppResponse.successData(eduSyncJhImportBatchIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "金华市教育同步导入批次表新增",description = "金华市教育同步导入批次表新增")
    @PostMapping(value = "/syncJhImportBatch0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSyncJhImportBatchVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduSyncJhImportBatchVO vo) {
        return AppResponse.successData(eduSyncJhImportBatchIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "金华市教育同步导入批次表修改",description = "金华市教育同步导入批次表修改")
    @PostMapping(value = "/syncJhImportBatch0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSyncJhImportBatchVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduSyncJhImportBatchVO vo) {
        return AppResponse.successData(eduSyncJhImportBatchIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "金华市教育同步导入批次表删除",description = "金华市教育同步导入批次表删除")
    @PostMapping(value = "/syncJhImportBatch0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduSyncJhImportBatchKeyVO vo) {
        eduSyncJhImportBatchIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }

    @Idempotent(expire = "PT2S") //2秒内防重复提交
    @Operation(summary = "获取金华同步导入类型", description = "获取金华同步导入类型")
    @PostMapping(value = "/syncJhImportBatch0007", produces = "application/json;charset=UTF-8")
    public AppResponse<List<JhSynCImportTypeVO>> getJhSyncImportType(@RequestBody BaseVO vo) {
        ArrayList<JhSynCImportTypeVO> result = new ArrayList<>();
        for (JhSyncImportEnum value : JhSyncImportEnum.values()) {
            JhSynCImportTypeVO jhSynCImportTypeVO = new JhSynCImportTypeVO();
            jhSynCImportTypeVO.setImportType(value.getType());
            jhSynCImportTypeVO.setImportTypeName(value.getName());
            result.add(jhSynCImportTypeVO);
        }
        return AppResponse.successData(result);
    }
}
